// setTimeout(function(){

	Date.prototype.format = function (fmt) { //author: meizz
		var o = {
			"M+": this.getMonth() + 1, //月份
			"d+": this.getDate(), //日
			"h+": this.getHours(), //小时
			"m+": this.getMinutes(), //分
			"s+": this.getSeconds(), //秒 fff
			"q+": Math.floor((this.getMonth() + 3) / 3), //季度
			"S": this.getMilliseconds() //毫秒
		};
		if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
		for (var k in o)
			if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
		return fmt;
	};
String.prototype.replaceAll = function(s1,s2) {
	return this.replace(new RegExp(s1,"gm"),s2);
}
var Bhl = {
	nodeName : "Bhl",
	nodeNamespace:"Bhl",
	objKey : "Bhl",
	baseObj : null,
	parentObj : null,
	objMap:{},
	getObjByNamespace:function(paramName){
		var objKey = paramName.replaceAll("\\.","_");
		return this.objMap[objKey];
	},
	setObjByNamespace:function(paramName,obj){
		var objKey = paramName.replaceAll("\\.","_");
		this.objMap[objKey] = obj;
	}
};
$.extend({
	bhl_ns:function(namespace,callback){
		var baseObj = Bhl;
		var baseNamespace = "Bhl"
		if(typeof Bhl.getObjByNamespace(namespace) === "undefined"){
			var currentObj = baseObj;
			var nameArray = namespace.split(".");
			if(nameArray[0]===baseNamespace){
				nameArray = nameArray.slice(1);
			}
			var domFlag = true;
			var tempNamespace = baseNamespace;
			for(var i = 0; i <nameArray.length ;i++){
				var tempNodename = nameArray[i];
				tempNamespace = tempNamespace + "." + tempNodename;
				var tempObj = currentObj[tempNodename];

				var tempOption = {
					nodeName : tempNodename,
					nodeNamespace:tempNamespace,
					baseObj : baseObj,
					parentObj : currentObj
				};

				if(domFlag){
					if(tempObj){
						currentObj = tempObj;
					}else{
						currentObj = $.bhl_ns_creat_obj(currentObj,tempOption);
						domFlag = false;
					}
				}else{
					currentObj = $.bhl_ns_creat_obj(currentObj,tempOption);
				}
			}
		};
		if(typeof callback === "function"){
			callback();
		}
	},
	bhl_ns_creat_obj:function(obj,option){
		var target = {
			bhl_option:option
		};
		obj[option.nodeName] = target;
		Bhl.setObjByNamespace(option.nodeNamespace,target);
		return target;
	}
});
$.bhl_ns("Bhl.utils.CommonUtil",function(){
	Bhl.utils.CommonUtil.ROOT_PATH = "";
	Bhl.utils.CommonUtil.getUrl = function(url) {
		var reUrl = "";
		if (url != null && url != "") {
			// url编码
			reUrl = Bhl.utils.CommonUtil.getRootPath() + encodeURI(url);
		}
		return reUrl;
	};
	Bhl.utils.CommonUtil.getRootPath = function(){
		var rePath = Bhl.utils.CommonUtil.ROOT_PATH;
		if("/"==rePath){
			rePath = "";
		}
		return rePath;
	};
});


//浏览器版本
$.bhl_ns("Bhl.utils.BrowserUtil",function(){
	Bhl.utils.BrowserUtil = {
		currentBrowserInfo:null,
		//获取浏览器信息 类型,版本号
		getBrowserInfo:function(){
			if(Bhl.utils.BrowserUtil.currentBrowserInfo == null){
				var browserMatch = Bhl.utils.BrowserUtil.uaMatch();
				Bhl.utils.BrowserUtil.currentBrowserInfo = browserMatch;
			}
			return Bhl.utils.BrowserUtil.currentBrowserInfo;
		},
		uaMatch:function(){
			var userAgent = navigator.userAgent;
			var ua = userAgent.toLowerCase();
			var rMsie = /(msie\s|trident.*rv:)([\w.]+)/,
				rFirefox = /(firefox)\/([\w.]+)/,
				rOpera = /(opera).+version\/([\w.]+)/,
				rChrome = /(chrome)\/([\w.]+)/,
				rSafari = /version\/([\w.]+).*(safari)/;
			var ua = userAgent.toLowerCase();
			var match = rMsie.exec(ua);
			if(match != null){
				return { browser : "IE", version : match[2] || "0" };
			}
			var match = rFirefox.exec(ua);
			if (match != null) {
				return { browser : match[1] || "", version : match[2] || "0" };
			}
			var match = rOpera.exec(ua);
			if (match != null) {
				return { browser : match[1] || "", version : match[2] || "0" };
			}
			var match = rChrome.exec(ua);
			if (match != null) {
				return { browser : match[1] || "", version : match[2] || "0" };
			}
			var match = rSafari.exec(ua);
			if (match != null) {
				return { browser : match[2] || "", version : match[1] || "0" };
			}
			if (match != null) {
				return { browser : "", version : "0" };
			}
		},
		isNewBrowserFlag:null,
		/**
		 * 是否是新型浏览器
		 * 临时的方法有待改进
		 */
		isNewBrowser:function(){
			if(Bhl.utils.BrowserUtil.isNewBrowserFlag==null){
				var browserInfo = Bhl.utils.BrowserUtil.getBrowserInfo();
				if(browserInfo.browser=="IE"&&(browserInfo.version-0.0)<10){
					Bhl.utils.BrowserUtil.isNewBrowserFlag = false;
				}else{
					Bhl.utils.BrowserUtil.isNewBrowserFlag = true;
				}
			}
			return Bhl.utils.BrowserUtil.isNewBrowserFlag;
		}
	}
});

/**
 * 菜单组件
 * 公有方法
 * 初始化一级菜单
 * Bhl.frame.Menu.initMenuLevelOne
 * 二级菜单点击操作
 * Bhl.frame.Menu.menuLevel2Click
 * 三级菜单点击操作
 * Bhl.frame.Menu.menuLevel3Click
 * 右侧菜单快捷访问
 * Bhl.frame.Menu.quicklyVisit
 * 页面跳转
 * Bhl.frame.Menu.pageJumpTo
 * 浏览器大小变化，重置menu显示效果
 * Bhl.frame.Menu.bindResize
 * 获取根根路径
 * Bhl.frame.Menu.getRootPath
 * 获取实际访问url
 * Bhl.frame.Menu.getUrl
 * 收起左侧菜单 当isCloseAll 整个收起 ，否则根据屏幕大小判断收起效果
 * Bhl.frame.Menu.closeLeftMenu(isCloseAll)
 */
$.bhl_ns("Bhl.frame.Menu",function(){
	/**
	 * public
	 */

	Bhl.frame.Menu.TransitionFlag = false;
	//菜单访问日志记录url
	Bhl.frame.Menu.MENU_LOG_URL = "/menu/menuManage/visitLog";
	//当前menu展开状态
	Bhl.frame.Menu.MENU_STATE = false;
	//当前访问的一级菜单CODE
	Bhl.frame.Menu.CurrentMenuLevelOneCode = "SY";
	//当前访问的二级菜单CODE
	Bhl.frame.Menu.CurrentMenuLevel2ActiveId = "";
	//当前访问的三级菜单CODE
	Bhl.frame.Menu.CurrentMenuLevel3ActiveId = "";
	//初始化一级菜单
	Bhl.frame.Menu.initMenuLevelOne = function(levelOneCode) {
		Bhl.frame.Menu.menuLevel1Click(levelOneCode, null);
	}
	//一级菜单点击操作
	Bhl.frame.Menu.menuLevel1Click = function(code, url,showLeftMenu,absolute,openNewWindow) {
		$("#frame-main-centerHtml").empty();
		if (code == "SY") {
			url = Bhl.frame.Menu.BHL_SY_PATH;
		}
		_menuActiveClassEdit(code, "level1");
		_centerDivLoadHandler(code, url,absolute,openNewWindow);
		Bhl.frame.Menu.CurrentMenuLevelOneCode = code;
		//当前访问的二级菜单CODE
		Bhl.frame.Menu.CurrentMenuLevel2ActiveId = "";
		//当前访问的三级菜单CODE
		Bhl.frame.Menu.CurrentMenuLevel3ActiveId = "";
	}
	//二级菜单点击操作
	Bhl.frame.Menu.menuLevel2Click = function(code, url, showLeftMenu,absolute,openNewWindow,args) {
		$("#frame-main-centerHtml").empty();
		_menuActiveClassEdit(code, "level2");
		_centerDivLoad(code, url,showLeftMenu,absolute,openNewWindow,args);
		if (!showLeftMenu) {
			_closeLeftMenu();
		}else{
			_openLeftMenu();
		}
		//当前访问的三级菜单CODE
		Bhl.frame.Menu.CurrentMenuLevel3ActiveId = "";
	}
	//三级菜单点击操作
	Bhl.frame.Menu.menuLevel3Click = function(level2code,code, url,showLeftMenu,absolute,openNewWindow,args) {
		$("#frame-main-centerHtml").empty();
		_menuActiveClassEdit(level2code, "level2");
		_menuActiveClassEdit(code, "level3");
		_centerDivLoad(code, url,showLeftMenu,absolute,openNewWindow,args);
		if(!showLeftMenu){
			_closeLeftMenu();
		}else{
			_openLeftMenu();
		}

	}
	//右侧菜单快捷访问
	Bhl.frame.Menu.quicklyVisit = function(code, url,absolute) {
		var crrentMenu = Bhl.frame.Menu.menuInfo[code];
		if(crrentMenu){
			if (crrentMenu['level'] == "level1") {
				Bhl.frame.Menu.menuLevel1Click(code, url,absolute);
			} else if (crrentMenu['level'] == "level2") {
				var level1_code = crrentMenu['level1_code'];
				_menuActiveClassEdit(level1_code, "level1");
				Bhl.frame.Menu.menuLevel2Click(code, url, false,absolute);
			} else if (crrentMenu['level'] == "level3") {
				var level1_code = crrentMenu['level1_code'];
				var level2_code = crrentMenu['level2_code'];
				_menuActiveClassEdit(level1_code, "level1");
				Bhl.frame.Menu.menuLevel3Click(level2_code,code, url,false,absolute);
			}
		}else{
			Bhl.frame.Menu.pageJumpTo(url);
		}

	}
	//页面跳转
	//isCloseAll 是否收起整个左侧菜单
	//isPostMethod 是否使用post方法
	Bhl.frame.Menu.pageJumpTo = function(url, paramObj,isCloseAll,isPostMethod) {
		$("#frame-main-centerHtml").empty();
		var q_url = Bhl.frame.Menu.getUrl(url);
		if(isPostMethod){
			$.ajax({
				url: url,
				type: "POST",
				data: paramObj,
				success: function(data){
					$("#frame-main-centerHtml").html(data);
				}
			})
		}else{
			$("#frame-main-centerHtml").load(q_url, paramObj,
				function(response, status, xhr) {
					_setElementHigth();
				});
		}
		if(isCloseAll){
			_closeLeftMenu(true);
		}

	}
	//浏览器大小变化，重置menu显示效果
	Bhl.frame.Menu.bindResize = function() {
		$(window).resize(function() {
			if (Bhl.frame.Menu.MENU_STATE) {
				_openLeftMenu(true);
			} else {
				_closeLeftMenu(!_hasLevel2Items(Bhl.frame.Menu.CurrentMenuLevelOneCode));
			}
		});
	}
	//获取根根路径
	Bhl.frame.Menu.getRootPath = function(){
		var rePath = Bhl.utils.CommonUtil.ROOT_PATH;
		if("/"==rePath){
			rePath = "";
		}
		return rePath;
	};
	//获取实际访问url
	Bhl.frame.Menu.getUrl = function(url) {
		var reUrl = "";
		if (url != null && url != "") {
			// url编码
			var urlContext=Bhl.frame.Menu.getRootPath();
			url=encodeURI(url);
			if(url.match(urlContext)){
				reUrl=url;
			}else{
				reUrl=urlContext+url;
			}
			reUrl=reUrl.replace(/\/\//g,"/");
		}
		return reUrl;
	};
	//收起左侧菜单 当isCloseAll 整个收起 ，否则根据屏幕大小判断收起效果
	Bhl.frame.Menu.closeLeftMenu = function(isCloseAll) {
		Bhl.frame.Menu.MENU_STATE = false;
		var screenSizes = $.AdminLTE.options.screenSizes;
		if ($(window).width() > (screenSizes.sm - 1)) {
			if (isCloseAll) {
				$(".wrapper").css("margin-left", -50);
			} else {
				$(".wrapper").css("margin-left", 0);
			}
			$(".menuCtrlLeft").addClass('fa-bars');
			$(".menuCtrlRight").removeClass('fa-bars');
			$("body").addClass('sidebar-collapse')
				.trigger('collapsed.pushMenu');
		} else {
			$(".wrapper").css("margin-left", 0);
			$("body").removeClass('sidebar-open').removeClass(
				'sidebar-collapse').trigger('collapsed.pushMenu');
		}

	};

	Bhl.frame.Menu.ooBtnCallBackArray = new Array();
	Bhl.frame.Menu.menuBtnClick = function(){
	};
	/**
	 * private
	 */
		//打开左侧菜单
	var _openLeftMenu = function(isOpenAll) {
			Bhl.frame.Menu.MENU_STATE = true;
			var screenSizes = $.AdminLTE.options.screenSizes;
			$(".wrapper").css("margin-left", 0);
			if ($(window).width() > (screenSizes.sm - 1)) {
				$(".menuCtrlLeft").removeClass('fa-bars')
				$(".menuCtrlRight").addClass('fa-bars');
				$("body").removeClass('sidebar-collapse').trigger(
					'expanded.pushMenu');
			} else {
				$("body").addClass('sidebar-open').trigger('expanded.pushMenu');
			}
		}
	//关闭左侧菜单
	//isCloseAll 是否整体收起
	var _closeLeftMenu = function(isCloseAll) {
		Bhl.frame.Menu.MENU_STATE = false;
		var screenSizes = $.AdminLTE.options.screenSizes;
		if ($(window).width() > (screenSizes.sm - 1)) {
			if (isCloseAll) {
				$(".wrapper").css("margin-left", -50);
			} else {
				$(".wrapper").css("margin-left", 0);
			}
			$(".menuCtrlLeft").addClass('fa-bars');
			$(".menuCtrlRight").removeClass('fa-bars');
			$("body").addClass('sidebar-collapse')
				.trigger('collapsed.pushMenu');
		} else {
			$(".wrapper").css("margin-left", 0);
			$("body").removeClass('sidebar-open').removeClass(
				'sidebar-collapse').trigger('collapsed.pushMenu');
		}

	}
	//根据一级菜单下是否有二级菜单判断菜单打开状态
	var _closeOrOpenLeftMenu = function(levelOneCode) {
		if (_hasLevel2Items(levelOneCode)) {
			_openLeftMenu(true);
		} else {
			_closeLeftMenu(true);
		}
	}
	//判断是否有二级菜单
	var _hasLevel2Items = function(levelOneCode) {
		if ($("#frame-level1_chlid_" + levelOneCode).find("li").length > 1) {
			return true;
		} else {
			return false;
		}

	}
	//设置顶部菜单激活样式
	var _setTopMenuActive = function(code) {
		$(".label_active").removeClass("label_active")
		$("#frame-level1_label_" + code).addClass("label_active");
	}
	//显示对应的二级目录
	var _showLevel2MenuList = function(levelOneCode) {
		$(".sidebar-menu").hide();
		$("#frame-level1_chlid_" + levelOneCode).show();
	}
	//设置右侧菜单点击样式
	var _menuActiveClassEdit = function(code, level) {
		if (level == "level1") {
			_showLevel2MenuList(code);
			_closeOrOpenLeftMenu(code);
			_setTopMenuActive(code);
		} else if (level == "level2") {
			var oldIdLevel2 = Bhl.frame.Menu.CurrentMenuLevel2ActiveId;
			if (oldIdLevel2) {
				$("#frame-" + oldIdLevel2).removeClass("active");
			}
			Bhl.frame.Menu.CurrentMenuLevel2ActiveId = "level2_" + code;
			$("#frame-" + Bhl.frame.Menu.CurrentMenuLevel2ActiveId).addClass("active");
		} else if (level == "level3") {
			var oldIdLevel3 = Bhl.frame.Menu.CurrentMenuLevel3ActiveId;
			if (oldIdLevel3 != "") {
				$("#frame-" + oldIdLevel3).removeClass("level3Active");
			}
			Bhl.frame.Menu.CurrentMenuLevel3ActiveId = "level3_" + code;
			$("#frame-" + Bhl.frame.Menu.CurrentMenuLevel3ActiveId).addClass("level3Active");
		}

	}
	//正文div内容加载
	var _centerDivLoad = function(code, url,showLeftMenu,absolute,openNewWindow,args) {
		var queryFlag = true;
		if(_isNeedWaitTransition(showLeftMenu)&&Bhl.utils.BrowserUtil.isNewBrowser()){
			WN.addTranEvent($("body").get(0),function(){
				queryFlag = false;
				_centerDivLoadHandler(code, url,absolute,openNewWindow,args);
			},1);

			setTimeout(function(){
				if(queryFlag){
					_centerDivLoadHandler(code, url,absolute,openNewWindow,args);
				}
			},3000);

		}else{
			_centerDivLoadHandler(code, url,absolute,openNewWindow,args);
		}
	}
	var _centerDivLoadHandler = function(code, url,absolute,openNewWindow,args) {
		var q_url = Bhl.frame.Menu.getUrl(url);
		//alert(q_url)
		if(openNewWindow=='true'||openNewWindow==true){
			window.open("http://"+q_url || '',"_blank","height="+window.screen.availHeight+",width="+window.screen.availWidth+",resizable=yes,status=yes,menubar=no,scrollbars=yes");
			return;
		}
		//绝对路径
		if(absolute=='true'||absolute==true){
			$("#frame-main-centerHtml").html("<iframe width='100%' height='1250' overflow-y='hidden' scrolling='no' frameborder='0' src='"+Bhl.frame.Menu.getRootPath()+url+"'> </iframe>");
		}else{
			if (q_url) {
				$("#frame-main-centerHtml").load(q_url, args ? args:null,
					function(response, status, xhr) {
						_setElementHigth();
					});
			}
		}
		if (url != null && url != "") {
			//记录访问日志
			_visitLog(code, url);
		}
	}
	var _isNeedWaitTransition = function(showLeftMenu){
		var reFlag = false;
		if(showLeftMenu){
			/*打开*/
			if($.AdminLTE.layout.isPhoneView()){
				if($("body").hasClass('sidebar-open')){
					reFlag = false;
				}else{
					reFlag = true;
				}
			}else{
				if($("body").hasClass('sidebar-collapse')){
					reFlag = true;
				}else{
					reFlag = false;
				}
			}
		}else{
			/*关闭*/
			//小屏 只要 sidebar-open 或 sidebar-collapse 就true
			if($.AdminLTE.layout.isPhoneView()){
				if($("body").hasClass('sidebar-open')){
					reFlag = true;
				}else {
					reFlag = false;
				}
			}
			//大屏
			else{
				if($("body").hasClass('sidebar-collapse')){
					reFlag = false;
				}else{
					reFlag = true;
				}
			}
		}


		return reFlag;
	}
	//提交菜单访问日志
	var _visitLog = function(code, url) {
		var pData = {
			"url" : url,
			"code" : code
		};
		var qUrl = Bhl.frame.Menu.getRootPath() + Bhl.frame.Menu.MENU_LOG_URL;
		$.ajax({
			url : qUrl,
			data : pData,
			success : function() {
			}
		});
	}

	var _BASE_HEIGTH = 75;
	var _ITEM_HEIGTH = 45;
	var _FOOT_HEIGTH = 50;
	//设置元素高度
	var _setElementHigth = function() {
		if ($.AdminLTE.layout) {
			$.AdminLTE.layout.fix();
		} else {
			$("body").css("height", "auto");
			$("#frame-main-centerHtml").css("height", "auto");
			var itemSize = $("#frame-level1_chlid_" + Bhl.frame.Menu.CurrentMenuLevelOneCode)
				.find("li").length;
			var main_sidebar_h = _BASE_HEIGTH + _ITEM_HEIGTH * (itemSize - 1);
			var main_content_h = $("#frame-main-centerHtml").height();
			var body_h = $("body").outerHeight();
			if (main_sidebar_h >= body_h) {
				if (main_sidebar_h >= main_content_h) {
					var cha = main_sidebar_h - body_h;
					$("#frame-main-centerHtml").css("height",
						main_sidebar_h - _FOOT_HEIGTH);
				} else {
					$("body").css("height", "auto");
					$("#frame-main-centerHtml").css("height", "auto");
				}
			}
		}
	}
});


/**
 * 历史操作处理组件
 * 公有方法
 * 回退一页,返回boolean 表示是否存在下次回退
 * Bhl.frame.Menu.history.getBefore
 * 前进一页，返回boolean 表示是否存在下次前进
 * Bhl.frame.Menu.history.getAfter
 * 保存访问的请求
 * Bhl.frame.Menu.history.save
 * 查询是否存在回退页
 * Bhl.frame.Menu.history.hasBefore
 * 查询是否存在前进页
 * Bhl.frame.Menu.history.hasAfter
 */
$.bhl_ns("Bhl.frame.Menu.history",function(){
	/**
	 * public
	 */

	//前进一页，返回boolean 表示是否存在下次前进
	Bhl.frame.Menu.history.getAfter = function(){
		var menuObj = _afterArray.shift();  /* 从后栈取出 */
		if(menuObj){
			_put(_beforeArray,menuObj); /* 压入到前栈  */
			menuObj.proceed(); /* 执行菜单方法  */
		}
		_setButtonStyle();
		return _afterArray.length>0 ? true : false;
	};
	//回退一页,返回boolean 表示是否存在下次回退
	Bhl.frame.Menu.history.getBefore = function(){
		var menuObj = _beforeArray.shift();  /* 从前栈取出 */
		if(menuObj){
			_put(_afterArray,menuObj); /* 压入到后栈  */
			if(menuObj.method=='initMenuLevelOne')
				_isNextIgnore=true;
			_echoData = menuObj.echoData;
			menuObj.proceed(); /* 执行菜单方法  */
		}
		_setButtonStyle();
		return _beforeArray.length>0 ? true : false;
	};
	//保存访问的请求
	Bhl.frame.Menu.history.save = function(menuObj){
		_setButtonStyle();
		_put(_beforeArray,menuObj);
	};
	//查询是否存在回退页
	Bhl.frame.Menu.history.hasBefore=function(){
		return _beforeArray.length>0 ;
	};
	//查询是否存在前进页
	Bhl.frame.Menu.history.hasAfter=function(){
		return _afterArray.length>0 ;
	};
	//添加回显参数
	Bhl.frame.Menu.history.addEchoData=function(echoDataObj){
		_echoData = echoDataObj;
	}
	//获取回显传参
	Bhl.frame.Menu.history.getEchoData=function(){
		return _currentMenu.echoData;
	}

	//获取当前菜单信息
	Bhl.frame.Menu.history.getCurrentMenu=function(){
		return _currentMenu;
	}

	/**
	 * private
	 */

	/* 当前菜单对象  */
	var _currentMenu = null;
	/* 回显参数 */
	var _echoData = null;
	/*  后退栈  */
	var _beforeArray = new Array();
	/*  前进栈  */
	var _afterArray = new Array();
	/*  允许保存的访问次数 */
	var _historySize = 10;
	/*  标记是否忽略下一次拦截*/
	var _isNextIgnore=false;
	/*  检查并设置前进后退的按钮样式 */
	var _setButtonStyle=function(){
		if(Bhl.frame.Menu.history.hasAfter()){
			$("#a_areaSideBar_forward").removeClass("right_float_6").addClass("right_float_5");
		}else{
			$("#a_areaSideBar_forward").removeClass("right_float_5").addClass("right_float_6");
		}
		if(Bhl.frame.Menu.history.hasBefore()){
			$("#a_areaSideBar_back").removeClass("right_float_6").addClass("right_float_5");
		}else{
			$("#a_areaSideBar_back").removeClass("right_float_5").addClass("right_float_6");
		}
	};
	/*  将访问保存到堆栈中*/
	var _put = function(array,obj){
		if(_currentMenu!=null){
			if(array.length>=_historySize){
				var b = array.pop();      /* 超出占容量，移除最先的对象 */
			}
			/* 判断是否有回显参数，如果有回显参数放入当前菜单对象，然后重置    by wangtao */
			if(_echoData != null){
				_currentMenu.echoData = _echoData;
				_echoData = null;
			}
			var lg = array.unshift(_currentMenu);  /* 压入栈首位 */
		}
		_currentMenu = obj;
	};

	/* 拦截一二三级菜单，保存到访问历史用  */
	// jQuery.aop.around( {target: Bhl.frame.Menu, method: 'menuLevel1Click'},
	//     function(invocation) {
	// 		if(!_isNextIgnore){
	// 			Bhl.frame.Menu.history.save(invocation);
	// 			_setButtonStyle();
	// 		}
	//     	_isNextIgnore=false;
	//         return invocation.proceed();
	//     }
	// );
	// jQuery.aop.around( {target: Bhl.frame.Menu, method: 'menuLevel2Click'},
	//     function(invocation) {
	//         Bhl.frame.Menu.history.save(invocation);
	//         _setButtonStyle();
	//         return invocation.proceed();
	//     }
	// );
	// jQuery.aop.around( {target: Bhl.frame.Menu, method: 'menuLevel3Click'},
	//     function(invocation) {
	//     	Bhl.frame.Menu.history.save(invocation);
	//         _setButtonStyle();
	//         return invocation.proceed();
	//     }
	// );
	// jQuery.aop.around( {target: Bhl.frame.Menu, method: 'pageJumpTo'},
	//     function(invocation) {
	//     	Bhl.frame.Menu.history.save(invocation);
	//     	_setButtonStyle();
	//     	if(invocation.arguments[1]&&
	//     			typeof(invocation.arguments[1]['startPage'])!="undefined"&&_beforeArray.length>0){
	//     		var prev=_beforeArray[0];
	//     		var startPage=invocation.arguments[1]['startPage'];
	//     		var args=prev.arguments;
	//     		switch(prev.method){
	//         		case 'pageJumpTo':
	//         			if(typeof(args[1])!='object'){
	//         				args[1]={'startPage':startPage};
	//         			}else{
	//         				args[1]['startPage']=startPage
	//         			}
	//         			break;
	//         		case 'menuLevel2Click':
	//         			args[4]={'startPage':startPage};
	//         			break;
	//         		case 'menuLevel3Click':
	//         			args[5]={'startPage':startPage};
	//         			break;
	//     		}
	//     	}
	//         return invocation.proceed();
	//     }
	// );
	// jQuery.aop.around( {target: Bhl.frame.Menu, method: 'initMenuLevelOne'},
	//      function(invocation) {
	// 		_isNextIgnore=true;
	//         Bhl.frame.Menu.history.save(invocation);
	//         _setButtonStyle();
	//         return invocation.proceed();
	//     }
	// );

});
/**
 * 信息提示组件
 * var bhlMsg = new Bhl.frame.MessageBox().showMessage(msg);
 * bhlMsg.hide();
 */
$(function(){
	$.bhl_ns("Bhl.frame.MessageBox",function(){
		Bhl.frame.MessageBox = function(){
			this.init.apply(this,arguments);
		}
		Bhl.frame.MessageBox.prototype = {
			//对象初始化
			init: function(){
				//创建html
				this._initView();
			},
			//显示提示信息
			showMessage: function(msg,state,timer){
				state = state || 'success';
				timer = timer || 5000;
				this.$this.removeClass('success')
					.removeClass('error')
					.addClass(state);
				this.$this.find('.modal-body').text(msg);
				this.$this.modal('show').find('.modal-dialog').css({
					"margin-top": function () {
						return  (($(window).height() / 2) - 120);
					}
				});
				var scope = this;
				window.setTimeout(function(){scope.hide()}, timer);
				return this;
			},
			//隐藏提示信息
			hide: function(msg){
				$(this).trigger('beforeHide');
				this.$this.modal('hide');
				$(this).trigger('afterHide');
			},
			//创建html
			_initView: function(msg){
				this.$this = $('<div class="modal error" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"></div>');
				this.$this.append('<div class="modal-dialog" role="document"><div class="modal-content">' +
					'<div class="modal-header">' +
					'<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>' +
					'<h4 class="modal-title">系统提示</h4></div>' +
					'<div class="modal-body"></div>' +
					'<div class="modal-footer">' +
					'<button type="button" class="btn btn-default" data-dismiss="modal">确&nbsp定</button>' +
					'</div></div></div></div>');
				this.$this.appendTo(document.body);
			},
			//自定义Event
			eventName:['beforeHide','afterHide']
		}
	})
	// 设置jQuery Ajax全局的参数 complete里做ajax返回结果的统一处理
	$.ajaxSetup({
		type: "POST",
		complete: [function(jqXHR, textStatus){
			//判断session过期
			if(jqXHR.responseText && jqXHR.responseText.indexOf('j_oa_security_check') != -1) {
				var msg = '登陆已超时，点击确认按钮返回登陆页面；点击取消按钮，按住键盘"Ctrl + N"，打开页面登录后，返回之前页面保存信息!';
				new Bhl.frame.MessageBox().showMessage(msg,'error',999999);
				return;
			}
		},function(jqXHR, textStatus){
			var brief = '';
			var isError = false;
			switch (jqXHR.status){
				case(0):
					//ajax请求被取消
					break;
				case(200):
					//成功
					//brief = "操作成功";
					//$('#errorModalDialog').addClass('modal-success');
					break;
				case(500):
					//显示自定义错误信息
					isError = true;
					var json = eval("(" + jqXHR.responseText + ")");
					brief = json.msg.brief;
					break;
				case(403):
					//没有权限
					isError = true;
					brief = "无权限执行此操作";
					break;
				case(408):
					//请求超时
					isError = true;
					brief = "请求超时";
					break;
				case(404):
					//404
					isError = true;
					brief = "访问资源未找到";
					break;
				default:
					isError = true;
					//未知错误
					brief = "未知错误:" + jqXHR.status;
			}
			if(isError){
				//alert("信息："+brief);
				new Bhl.frame.MessageBox().showMessage(brief,'error',999999);
			}
		} ]
	});
});

//报告期工具类
$.bhl_ns("Bhl.date.Utils",function(){
	Bhl.date.Utils.deatLine = "";
	//获取deadLine
	Bhl.date.Utils.getDeadLine = function(){
		if(Bhl.date.Utils.deatLine&&Bhl.date.Utils.deatLine!=""){
			return Bhl.date.Utils.deatLine-0;
		}else{
			return 27;
		}
	};
	//根据deadLine获取当前月份deadLine
	Bhl.date.Utils.getDeadLineDate = function(deadline){
		if(deadline){}else{
			deadline = Bhl.date.Utils.getDeadLine();
		}
		var date = new Date();
		var year = date.getFullYear();
		var month = date.getMonth() + 1;
		var bDate = new Date(year + '/' + month + '/' + deadline);
		var eDate = new Date(year + '/' + (month + 1) + '/' + (deadline - 1))
		if (!(date > bDate && date < eDate)) {
			bDate.setDate(1);
			bDate.setDate(-1);
			year = bDate.getFullYear();
			month = bDate.getMonth() + 1;
		}
		return year + '' + (month < 10 ? "0" + month : month);
	};
});
//初始化DateLine
Bhl.date.Utils.deatLine = '27';

// },500)